<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head th:replace="head :: commonHead('发票')">

</head>

<body>

<div th:replace="head :: header"></div>

<!-- 主体内容 -->
<div class="user_container clearfix">

    <div th:replace="content/personal/left :: body"></div>

    <!-- 右侧内容 -->
    <div class="right_boxwrap">
        <div class="user_right_box">
            <div class="user_right_box_title">
                <div class="user_right_box_title_l">
                    <em></em>
                    <h3>我的发票</h3>
                </div>
            </div>

            <div class="goods_content">
                <div class="goods_con_title clearfix">
                    <div class="goods_con_title_right">
                        <input type="text" id="search-word" value="" placeholder="摄影师名称/作品名称"/>
                        <a href="javascript:void(0)" id="search-btn"><i class="iconfont icon-fangdajing"></i></a>
                    </div>
                </div>

                <div class="goods_nav">
                    <ul class="clearfix">
                        <li style="width: 45%;">订单详情</li>
                        <li style="width: 23%;">发票类型</li>
                        <li style="width: 16%;">全部状态</li>
                        <li>操作</li>
                    </ul>
                </div>

                <div class="goods_con">

                </div>

            </div>

        </div>
    </div>
</div>

<div th:replace="foot :: body"></div>

</body>

<script type="text/javascript" charset="utf-8" th:src="${#request.getAttribute('ctx') + '/static/front/js/home.js'}"></script>

<script th:inline="javascript">

    function load() {
        var search = $('#search-word').val();
        $.ajax({
            type: 'get',
            url: '/personal/receipt/api/list',
            data: {
                searchWord: search
            },
            dataType: 'text',
            cache: true,
            async: false,
            success: function (result) {
                $('.goods_con').html(result);
            },
            error: function (e) {
                ELEMENT.Message.error(Messages.ERROR);
            }
        })
    }

    $(function() {

        load();

        $('#search-btn').click(function () {
            load();
        })

        $('.icon-del').click(function () {
            var _self = this;
            var id = $(this).attr('data-item-id');
            $.ajax({
                type: 'delete',
                url: '/order/delete/' + id,
                beforeSend: function (xhr) {
                    xhr.setRequestHeader($("meta[name='_csrf_header']").attr("content"), $("meta[name='_csrf']").attr("content"));
                },
                success: function (result) {
                    if (result.status = Messages.HTTP_STATUS.SUCCESS) {
                        $(_self).parent().parent().parent().remove();
                        ELEMENT.Message.success(Messages.SUCCESS);
                        if ($(_self).parent().parent().parent().length == 0) {
                            $('.goods_con_box').show();
                        }
                    } else {
                        ELEMENT.Message.error(Messages.DELETE_FAILED);
                    }
                },
                error: function(e) {
                    ELEMENT.Message.error(Messages.ERROR);
                }
            })
        })
    })
</script>

</html>
